Skip to content

The Rust SDK retries pre-dispatch refusals and classifies errors - #1684

Merged
zlareb1 merged 2 commits into
ClickHouse:mainfrom
yorkhellen:feat/rust-sdk-retry-errors
Nov 28, 2026
Merged

zlareb1 merged 2 commits into
ClickHouse:mainfrom
yorkhellen:feat/rust-sdk-retry-errors

Conversation

@yorkhellen

@yorkhellen yorkhellen commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #52

Changelog category

  • Improvement

Changelog entry

The Rust SDK paces rate-limited operations within the configured wait budget and retries eligible responses that indicate the operation did not run. It adds typed error categories, retry hints, and accessors for precondition and wrong-cell details while preserving the raw response fields.

Why

A request refused before execution can be sent again without duplicating a write. When a request may have executed, the client still needs the operation's idempotency policy. Callers can use typed errors to decide how to recover without parsing error messages.

Scope and risk

  • Operation calls can resend after 429 even when the operation is not idempotent. Operation and direct route calls return the original 429 when the wait exceeds the remaining pacing budget.
  • HTTP 408 and AUTH_UNAVAILABLE can be retried on non-idempotent operations under the configured status policy. Other HTTP failures and ambiguous transport failures still do not trigger automatic resends for non-idempotent operations.
  • Add ErrorKind, ErrorCategory, and typed accessors for current_sha256, org, and cell. retryable() provides an error hint; automatic resends still follow the client policy.

Compatibility, rollout and rollback

  • Wire: no server operations, fields, or defaults change.
  • Operator steps: none. This PR does not bump the crate version.
  • Documentation: the crate README describes the source SDK. Update the website's Rust SDK reference after the next crate release is available on crates.io so the examples match the published API.
  • Rollback: revert the SDK change. No stored data changes.

Tests

  • Rust stable: 99 client tests and 7 doctests passed. Rust 1.84.1: 117 client tests passed with blocking; Clippy passed for the library and client tests.
  • The HTTP regression confirms that Retry-After: 3600 returns 429 after one request with the default budget. Client tests also check send counts for 408, AUTH_UNAVAILABLE, and ordinary 503.
  • make format lint typecheck and the documentation checks passed locally.

AI assistance in the code

  • AI-generated (TRAE). The changes were reviewed and checked with the tests above.
  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass.
  • Repository text passes the public-copy check.
  • Commits are signed off.
  • Hosted CI passes.

Note

Medium Risk
Client retry/idempotency semantics changed for 429, 408, AUTH_UNAVAILABLE, and ambiguous 5xx on writes—callers may see different automatic resends and retryable() hints without server wire changes.

Overview
The Rust SDK gains typed API errors (ErrorKind, ErrorCategory) and resolver methods on Error / ApiError—kind(), category(), retryable()—plus accessors for precondition (current_sha256) and wrong-cell (org, cell) details while keeping raw response fields. These are exported from lib.rs and documented in the README (with a note that published 0.1.1 still exposes raw fields).

Retry and pacing behavior changes: HTTP 429 is paced on every operation (not only idempotent ones). Pacing waits for the server hint only when it fits the remaining sleep budget; hints over budget or zero wait return 429 without resending (no separate 5s cap per round). After dispatch, status retries still require idempotence except when the response proves the handler did not run (408, AUTH_UNAVAILABLE). On final failure, mark_maybe_applied marks ambiguous 5xx on non-idempotent calls (and unsafe route methods) as non-retryable when the body did not declare retryability.

Integration tests (retry_scope, client, routes, blocking) lock in the new pacing, retry eligibility, and typed error surfaces.

Reviewed by Cursor Bugbot for commit 9084a70. Bugbot is set up for automated code reviews on this repo. Configure here.

Pace rate-limit responses within the wait budget and allow configured status retries when the operation did not run. Resolve typed error hints without removing the raw response fields.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 28, 2026 4:55am UTC
loom-telemetry Ready Ready Preview Nov 28, 2026 4:55am UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 19d499a. Configure here.

Comment thread sdk/rust/src/client.rs Resolved
@zlareb1 zlareb1 self-assigned this Nov 28, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A raw 503 on a route write still yields retryable() == true. request and request_json return the parsed error directly, so an upload caller following the hint can repeat a write after the route commits. Apply the same ambiguity handling to route writes and cover a 503 without a retry flag in the route tests. Existing thread

Update the Client::call method docs as well. They promise that unknown operations retry only before connection, but the new 429 and pre-dispatch status paths also resend those operations.

A route can commit a write before a 5xx response arrives. Reuse the operation error classification so an undeclared retry hint does not invite a duplicate write. Document when unknown operations can be resent.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route request path clears the retry hint for an ambiguous 5xx after a write and preserves it for reads. The new regression covers both cases. The operation docs describe the retry and pacing paths.

@zlareb1
zlareb1 merged commit 465de4c into ClickHouse:main Nov 28, 2026
71 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants